import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/task/process_directory_tree_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/task/process_exec_entity.dart';

class ProcessExecListCtrl extends GetxController {
  final tree = Get.arguments as ProcessDirectoryTreeEntity?;

  String? search;

  /// 需要我审批的流程
  final items = <ProcessExecEntity>[];
  Future<void> getPages() async {
    final resp = await HttpUtil().generateGetRequest<List<ProcessExecEntity>>(
      '${Interface.mainBaseUrl}/process//processDirectory/getProcessTemplateList',
      queryParameters: {
        'processDirectoryId': tree?.treeId,
        'type': '2',
        'processName': search,
      },
    ).execute();
    resp.onSuccess((result) {
      if (result.data != null) {
        items.clear();
        items.addAll(result.data!);
        update();
      }
    });
  }

  @override
  void onInit() {
    super.onInit();
    getPages();
  }
}
